package listener;

import dao.UserDaoImpl;
import utils.connect.ConnectSqlDaoImpl;
import utils.string.session.SessionStringUtil;
import utils.string.sql.T_User;
import vo.User;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;

public class AllUserListener implements HttpSessionListener {
    //这个对象是通过服务器启动后进行监听，得到user的用户信息


    @Override
    public void sessionCreated(HttpSessionEvent se) {
        UserDaoImpl userDao = new UserDaoImpl();
        HashMap allUsers = new HashMap();
        allUsers =userDao.selectAll();
        HttpSession session = se.getSession();
        session.setAttribute(SessionStringUtil.ALL_USERS,allUsers);
    }
}
